package com.example.cuibo.basicarray;

/**
 * Created by cuibo on 2017/10/30.
 */

public class 数组 {
    double[] myList;
    int[] arr = {1,2,3,4,5,6,7,8};
    public void function(){

        // 二分查找法
        // 返回值Int int key

    }
    public static int halfSearch(int[] array, int key){
        int min = 0;// 记录最小索引
        int max = array.length - 1;// 记录最大索引
        int mid = (min + max) >> 2;// 等效于（min + max） / 2
        while (array[mid] != key){
            if (key < array[mid]){
                max = mid - 1;
            }else if (key > array[mid]){
                min = mid + 1;
            }
            if (min > max){
                return -1;
            }
            mid = (min + max) >> 1;
        }
        return mid;
    }
    // 数字转字符串
    int num = 100;
    String x = num + "";
    String y = String.valueOf(num);


}
